package innovacion.servlet.idea;

import innovacion.excepcion.DAOExcepcion;
import innovacion.modelo.Usuario_Permitido_Idea;
import innovacion.negocio.Gestion_Usuario_Permitido_Idea;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class IdeaListarPermisoServlet
 */
@WebServlet("/IdeaListarPermisoServlet")
public class IdeaListarPermisoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public IdeaListarPermisoServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String idea = request.getParameter("id");
		int coidea=Integer.parseInt(idea);
		String titulo=request.getParameter("tit");
		request.setAttribute("coidea",idea );
		request.setAttribute("title",titulo );
		
		Gestion_Usuario_Permitido_Idea negocio = new Gestion_Usuario_Permitido_Idea();
		try {
			Collection<Usuario_Permitido_Idea> lista = negocio.listar_permitidos(coidea);
			request.setAttribute("listar_usuario", lista);
			RequestDispatcher rd = request.getRequestDispatcher("listar_permisos.jsp");
			rd.forward(request, response);

		} catch (DAOExcepcion e) {
			System.out.println(e.getMessage());
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
		}
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
	}

}
